package main

import (
	"log"
	"net/http"
)

// 标准http库处理请求
func main() {

	http.HandleFunc("/", indexHandler)
	http.HandleFunc("/hello", helloHandler)
	log.Fatal(http.ListenAndServe(":9999", nil))
}

func indexHandler(w http.ResponseWriter, req *http.Request) {
	w.WriteHeader(http.StatusOK)
	w.Write([]byte("welcome gee web index!"))
}

func helloHandler(w http.ResponseWriter, req *http.Request) {
	//http.Request.ULR.Query() 返回请求的querystring
	//http.Request.Form 返回请求的form
	for k, v := range req.URL.Query() {
		log.Printf("request key: %s, val: %s\n", k, v)
	}
	w.WriteHeader(http.StatusOK)
	w.Write([]byte("hello gee"))
}
